//路由表
// 1.将指定的路由地址切换成对应的模块
import Router from "vue-router"
import Vue from "vue"
// 2.在vue中加载路由模块
Vue.use(Router)

// 3.写路由表信息
var routes = [
    // {
    //     // 动态参数
    //     path:"/index",
    //     component:()=>import("@/index.vue"),
    //     children:[
    //         {
    //             path:"/shop",
    //             component:()=> import("@/components/shop.vue"),
    //                     beforeEnter:(to,from,next) =>{
    //                         console.log("独享守卫",from,to);
    //                         next();
    //                     }
    //         },
    //         {
    //             path:"/shopcar",
    //             component:()=> import("@/components/shopcar.vue")
    //         }
    //     ]
    // },
    {
        path:"/hw2",
        component:()=> import("@/components/HelloWorld.vue")
    },
    // {
    //     path:"/hello",
    //     component:()=> import("@/components/hello.vue")
    // },
    {
         path: "/",
         redirect: "/login", //默认打开
    },

    {
        path:"/login",      
        component:()=> import("@/views/Login.vue")
       
    },
    {
        path:"/index",
        component:()=> import("@/index.vue")
    },
    
    
]
// 4.创建路由对象
export default new Router({
    routes//设置路由表
})
// 防止连续点击多次路由报错
let routerPush = Router.prototype.push;
let routerReplace = Router.prototype.replace;
// push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(err => err)
}
// replace
Router.prototype.replace = function push(location) {
  return routerReplace.call(this, location).catch(err => err)
}

